package wangbaguanlixitong.servlet;

import wangbaguanlixitong.dao.HyDao;
import wangbaguanlixitong.model.Hy;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import java.text.ParseException;

/**
 * 添加会员的servlet
 */
@WebServlet(name = "FindServlet",urlPatterns = "/addhy")
public class HYFindServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("text/html;charset=utf-8");
        Hy hy = new Hy();
        HyDao hydao = new HyDao();

        //得到当前页面
        String card =request.getParameter("card");
        String name =request.getParameter("name");
        String idcard =request.getParameter("idcard");
        String sex =request.getParameter("sex");
        String age =request.getParameter("age");
        String tel =request.getParameter("tel");
        String yuan =request.getParameter("yuan");

        hy.setCard(card);
        hy.setName(name);
        hy.setIdcard(idcard);
        hy.setSex(sex);
        hy.setAge(age);
        hy.setTel(tel);
        hy.setYuan(yuan);

        hydao.add(hy);

        request.getRequestDispatcher("addhuiyan.jsp").forward(request,response);
    }





    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       request.getRequestDispatcher("addhuiyan.jsp").forward(request,response);
    }
}
